﻿using DataAccess.DTO;
using DataAccess.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using XYD.DataAccess;
using XYD.Framework.Data;
using XYD.Framework.Data.Dapper;

namespace DataAccess.DAL
{
 

   public class SearchKeyWordDAL : BaseDAL
   {


       public static bool Insert(SearchKeyWord pro)
       {
           return CONN_TopicSharing.Insert<SearchKeyWord>(pro);
       }
       /// <summary>
       /// 插入搜索日志
       /// </summary>
       /// <param name="AgentID">代理ID</param>
       /// <param name="By_id">商家ID</param>
       /// <param name="SearchType">搜索类型，1=网站2=微信群3=qq群</param>
       /// <param name="SearchKey">搜索关键词</param>
       /// <param name="SearchUserName">搜索用户在群里的昵称</param>
       /// <param name="SorlCount">搜索返回的条数</param>
       /// <param name="Wxq_id">微信群名称</param>
       /// <param name="IP">用户IP</param>
       public static void InsertKeyWord(int AgentID,int By_id,int SearchType,string SearchKey,string SearchUserName,int SorlCount,string Wxq_id,string IP,string Desc)
       {
           SearchKeyWord m = new SearchKeyWord();
           m.AgentID=AgentID;
           m.promoter_id = By_id;
           m.SearchDate=DateTime.Now;
           m.SearchType = SearchType;
           m.SearchKey = SearchKey;
           m.SearchUserName=SearchUserName;
           m.SorlCount=SorlCount;
           m.Wxq_id = Wxq_id;
           m.IP = IP;
           m.Des = Desc;
           Insert(m);
       }
       public static List<SearchKeyWord> ListPage(string strWhere, string orderbys, int pagesize, int pageindex, out int count)
       {
           List<SearchKeyWord> list = new List<SearchKeyWord>();
           if (string.IsNullOrEmpty(orderbys))
               orderbys = " id desc";
           list = CONN_TopicSharing.SQLPager<SearchKeyWord>("*", " SearchKeyWord ", strWhere, "", "", orderbys, pagesize, pageindex, out count, null).ToList();
           return list;
       }
   }
}
